/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BL;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author sundas
 */
@Entity
@Table(name = "stock", catalog = "newPurchase", schema = "", uniqueConstraints = {@UniqueConstraint(columnNames = {"stockId"})})
@NamedQueries({@NamedQuery(name = "Stock.findAll", query = "SELECT s FROM Stock s"), @NamedQuery(name = "Stock.findByStockId", query = "SELECT s FROM Stock s WHERE s.stockId = :stockId"), @NamedQuery(name = "Stock.findByTaxRate", query = "SELECT s FROM Stock s WHERE s.taxRate = :taxRate"), @NamedQuery(name = "Stock.findByProductDateReceive", query = "SELECT s FROM Stock s WHERE s.productDateReceive = :productDateReceive"), @NamedQuery(name = "Stock.findByComments", query = "SELECT s FROM Stock s WHERE s.comments = :comments")})
public class Stock implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "stockId", nullable = false)
    private Integer stockId;
    @Column(name = "taxRate", precision = 12)
    private Float taxRate;
    @Basic(optional = false)
    @Column(name = "productDateReceive", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date productDateReceive;
    @Basic(optional = false)
    @Column(name = "Comments", nullable = false, length = 150)
    private String comments;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "stock")
    private Collection<Stockproduct> stockproductCollection;
    @JoinColumn(name = "supplierId", referencedColumnName = "supplierId")
    @ManyToOne
    private Supplier supplierId;
    @JoinColumn(name = "orderId", referencedColumnName = "orderId")
    @ManyToOne
    private Prodorder orderId;

    public Stock() {
    }

    public Stock(Integer stockId) {
        this.stockId = stockId;
    }

    public Stock(Integer stockId, Date productDateReceive, String comments) {
        this.stockId = stockId;
        this.productDateReceive = productDateReceive;
        this.comments = comments;
    }

    public Integer getStockId() {
        return stockId;
    }

    public void setStockId(Integer stockId) {
        this.stockId = stockId;
    }

    public Float getTaxRate() {
        return taxRate;
    }

    public void setTaxRate(Float taxRate) {
        this.taxRate = taxRate;
    }

    public Date getProductDateReceive() {
        return productDateReceive;
    }

    public void setProductDateReceive(Date productDateReceive) {
        this.productDateReceive = productDateReceive;
    }

    public String getComments() {
        return comments;
    }

    public void setComments(String comments) {
        this.comments = comments;
    }

    public Collection<Stockproduct> getStockproductCollection() {
        return stockproductCollection;
    }

    public void setStockproductCollection(Collection<Stockproduct> stockproductCollection) {
        this.stockproductCollection = stockproductCollection;
    }

    public Supplier getSupplierId() {
        return supplierId;
    }

    public void setSupplierId(Supplier supplierId) {
        this.supplierId = supplierId;
    }

    public Prodorder getOrderId() {
        return orderId;
    }

    public void setOrderId(Prodorder orderId) {
        this.orderId = orderId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (stockId != null ? stockId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Stock)) {
            return false;
        }
        Stock other = (Stock) object;
        if ((this.stockId == null && other.stockId != null) || (this.stockId != null && !this.stockId.equals(other.stockId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "DB.Stock[stockId=" + stockId + "]";
    }

}
